package com.prs.crm.dao.impl;

import java.util.Collection;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.prs.crm.dao.QueryDao;

public class QueryDaoImpl extends HibernateDaoSupport implements QueryDao{

	@SuppressWarnings("unchecked")
	public Object load(Class cls,java.io.Serializable id)
	{
		return this.getHibernateTemplate().load(cls, id);
	}
	
	public Collection<?> query(final DetachedCriteria criteria)
	{
		 return (Collection<?>)this.getHibernateTemplate().execute(
					new HibernateCallback()
					{
						public Object doInHibernate(Session session) throws HibernateException {
				        
				        	return criteria.getExecutableCriteria(session).list();
				        }   
					}
			);
	}
}
